<%@ page import="java.util.List" %>
<%@ page import="com.entity.Blog" %><%--
  Created by IntelliJ IDEA.
  User: Elle
  Date: 2022/6/30
  Time: 10:12
  jstl标签
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>使用JSTL显示数据</title>
</head>
<style>
    td{
        border: 1px solid;
        width: 120px;
    }
</style>
<body>
<table>
    <tr>
        <td>序号</td>
        <td>id</td>
        <td>用户id</td>
        <td>内容</td>
        <td>来源</td>
    </tr>
    <%--
        <c:forEach >
        var:循环中的变量
        items：循环对象【数组、集合】
    --%>
    <c:forEach var="tmp" items="${blogList}"  varStatus="index">
        <tr <c:if test="${tmp.fromBid!=0}">style="background-color: aquamarine"</c:if> >
            <td>${index.count}</td>
            <td>${tmp.id}</td>
            <td>${tmp.uid}</td>
            <td>${tmp.content}</td>
            <td>
<%--                    ${tmp.fromBid==0?"原创":"转载"}--%>
                    <%--选择结构： 单if / choose--%>
                        <c:choose>
                            <c:when test="${tmp.fromBid==0}">原创</c:when>
                            <c:when test="${tmp.fromBid==1}">转载</c:when>
                            <c:otherwise>未知</c:otherwise>
                        </c:choose>
<%--                    <c:if test="${tmp.fromBid==0}">--%>
<%--                        原创--%>
<%--                    </c:if>--%>
<%--                    <c:if test="${tmp.fromBid!=0}">--%>
<%--                        转载--%>
<%--                    </c:if>--%>
            </td>
        </tr>
    </c:forEach>
</table>

</body>
</html>
